package client.bean;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.google.gwt.user.client.rpc.IsSerializable;

public class Plan implements IsSerializable {

	/**
	 * Boolean means if user accepted the invation
	 */
	private Map<Member, Boolean> members = new HashMap<Member, Boolean>();

	private int id;
	private String name;
	private String description;
	private Date startTime;
	private Date endTime;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	public Map<Member, Boolean> getMembers() {
		return members;
	}

	public void addMember(Member member) {
		members.put(member, false);
	}

	@SuppressWarnings("RedundantIfStatement")
	@Override
	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (o == null || getClass() != o.getClass())
			return false;

		Plan plan = (Plan) o;

		if (description != null ? !description.equals(plan.description) : plan.description != null)
			return false;
		if (endTime != null ? !endTime.equals(plan.endTime) : plan.endTime != null)
			return false;
		if (members != null ? !members.equals(plan.members) : plan.members != null)
			return false;
		if (name != null ? !name.equals(plan.name) : plan.name != null)
			return false;
		if (startTime != null ? !startTime.equals(plan.startTime) : plan.startTime != null)
			return false;

		return true;
	}

	@Override
	public int hashCode() {
		int result = name != null ? name.hashCode() : 0;
		result = 31 * result + (description != null ? description.hashCode() : 0);
		result = 31 * result + (startTime != null ? startTime.hashCode() : 0);
		result = 31 * result + (endTime != null ? endTime.hashCode() : 0);
		result = 31 * result + (members != null ? members.hashCode() : 0);
		return result;
	}

	@Override
	public String toString() {
		return "Plan{" + "name='" + name + '\'' + ", description='" + description + '\'' + ", startTime=" + startTime + ", endTime=" + endTime + ", members=" + members + '}';
	}
}
